home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
OPTANS10.ARJ
/
OPTANSI.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-06-13
|
5KB
|
178 lines
/******************************************************************************
OptANSI Library
Copyright 1992 Michael Dannov
This source is subject to all restrictions specified by the licensing agreement
******************************************************************************/
#if !defined(__OPTANSI_H)
#define __OPTANSI_H
#ifdef __cplusplus
#define EXTERN extern "C"
#else
#define EXTERN extern
#endif
#if defined(_aFN)
/* COMPILATION RULES: ONLY VALID WHILE COMPILING SOURCE CODE */
// Defined if source code is registered. 0 only for creation of demo library.
#define REGISTERED 0
// Set this define to 1 if you want size considerations to supercede speed
#define SIZE 0
// Set this if you wish to compile in NANSI function extensions
#define NANSI 0
#else // For external code
EXTERN char ashortcuts;
EXTERN char axpos;
EXTERN char aypos;
EXTERN char acurattr;
#endif // _aFN
/* Compilation Definitions */
// ashortcuts flags
#define aBKSP 1
#define aLF 2
#define aCR 4
#define aCLRSCR 8
#define aRESET 64
#define aNANSI 128
#define anotshort(no) ashortcuts=(255-no)
#define ashort(is) ashortcuts=(is);
#define ashortdos() ashortcuts=(aBKSP | aCR | !aLF | !aCLRSCR | aRESET)
#define ashorttelecom() ashortcuts=(!aBKSP | aCR | aLF | aCLRSCR | aRESET);
/* User Types */
#if !defined(__COLORS)
#define __COLORS
enum COLORS {
BLACK, /* dark colors */
BLUE,
GREEN,
CYAN,
RED,
MAGENTA,
BROWN,
LIGHTGRAY,
DARKGRAY, /* light colors */
LIGHTBLUE,
LIGHTGREEN,
LIGHTCYAN,
LIGHTRED,
LIGHTMAGENTA,
YELLOW,
WHITE
};
#define BLINK 128 /* blink bit */
#endif
#define HIGHLIGHT 8 /* highlight bit */
#define ATTR(fore, back) (char)((back<<4) | fore)
struct acolorset {
unsigned fr:3; // Foreground Color (0-7)
unsigned h: 1; // Highlight bit (0-1)
unsigned bk:3; // Background Color (0-7)
unsigned b: 1; // Blinking bit (0-1)
};
union acolorunion {
struct acolorset bf;
char clr;
};
#define SKEY(key) (key<<8)
#define ESC 27
#define SP_ONE 255
#if !defined(__CONIO_H)
enum text_modes { BW40=0, C40, BW80, C80 };
#endif
enum agraphic_modes { G320_200=4, G320_200G, G640_200BW, aCURSORWRAP,
G320_200V=13, G640_200V, G640_350V=16, G640_480BWV, G640_480V, G300_200V,
ROWS43=43, ROWS50=50, aBIOSTTY=97, aFASTSCROLL, aGRAPHICSCURSOR };
#define aWRITE_TTY aBIOSTTY
#define aBIOSTTY aBIOSTTY
/* Prototypes */
int ainit();
char * agotoxy(char x, char y);
char * adown(char y);
char * aleft(char x);
char * asavecursor();
char * arestorecursor();
char * aclrscr();
char * aclreol();
char * acolor(char nc);
char * ahighlight();
char * ablink();
char * acmd(char num, char cmd);
unsigned awherexy(char *s);
char * atest();
char * atest1();
int aresult(char *s);
int aresult1();
int aresult2();
char *akeyboard(int key, char *str, char *buf);
char *amode(int mode, char cmd);
#define atextattr(nc) acolor(nc)
#define atextcolor(nc) acolor( (acurattr&240) | nc )
#define aforcecolor(nc) acurattr^=255;acolor(nc)
#define atextbackground(nc) acolor( (acurattr&15) | (nc<<4) )
#define ahighvideo() ahighlight()
#define anohighlight() acolor(acurattr & 247)
#define alowvideo() anohighlight()
#define anormvideo() anohighlight()
#define anoblink() acolor(acurattr & 127)
#define aresetcolor() acolor(7)
#define aunderline(fn) acmd(4, 'm'); fn
#define areverse(fn) acmd(7, 'm'); fn
#define ainvisible(fn) acmd(8, 'm'); fn
#define aforcegotoxy(x, y) axpos=255;aypos=255;agotoxy(x, y)
#define aup(y) acmd(y, 'A'); aypos += y
#define aright(x) acmd(x, 'C'); axpos += x
#define ahome() agotoxy(1, 1)
#define aclrbol() acmd(SP_ONE, 'K') // Rare Implementation
#define aclrline() acmd(2, 'K') // Rare Implementation
#define aclrsrnbelow() acmd(0, 'J') // Rare Implementation
#define aclrsrnabove() acmd(SP_ONE, 'J') // Rare Implementation
#define asetmode(mode) amode(mode, 'h')
#define aresetmode(mode) amode(mode, 'l')
#define atextmode(mode) asetmode(mode)
#define acursorwrap() asetmode(7)
#define anocursorwrap() aresetmode(7)
#define aupdatexy() axpos=wherex(); aypos=wherey()
#define aupdatexy1() axpos=*(char far *)(0x00000450L)+1; aypos=*(char far *)(0x00000451L)+1
// _wherexy(); y=_AL+1; x=_AH+1
// for NANSI and FANSI
#define adim() alowvideo()
#define anoinvisible(fn) acmd(28, 'm'); fn
#define ainsline(y) acmd(y, 'L') // NANSI Implementation
#define adelline(y) acmd(y, 'M') // NANSI Implementation
#define ainschar(x) acmd(x, '@') // NANSI Implementation
#define adelchar(x) acmd(x, 'P') // NANSI Implementation
#endif // _OPTANSI_H